#include "libc/stdint.h"
#include "driver/pl031/time.h"

typedef void (*function)(char*);

char* input_name[256] = {
    "uname",
    "date"
};

void uname(char* str){
    printk("lzwos v0.1");
}

void date(){
    time ti = {0};
    get_current_time(&ti);
    printk("Time: %d-%d-%d %d:%d:%d", ti.year, ti.month, ti.day, ti.hour, ti.minute, ti.second);
}

function funs[]={
    uname,
    date
};



void on_receive(char *BUFFER){
    if(!strcmp(BUFFER, "")){
        printk("\r\n");
        bool flag = false;

        for(uint32_t i = 0; i < 256; ++i){
            if(strcmp(input_name[i], BUFFER)){
                funs[i](BUFFER);
                flag = true;
                break;
            }
        }

        if (!flag) {
            printk("command not found: %s", BUFFER);
        }
    }
    printk("\r\n ➜ lzwos: ");
    // printk("\r\n%s\r\n", BUFFER);
}

